<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link th:href="@{/ajax/libs/summernote/summernote.css}" rel="stylesheet"/>
<link th:href="@{/ajax/libs/summernote/summernote-bs3.css}" rel="stylesheet"/>
<body class="white-bg">
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-notify-edit" th:object="${notify}">
        <input id="id" name="id" th:field="*{id}" type="hidden">
        <div class="form-group">
            <label class="col-sm-3 control-label">类型：</label>
            <div class="col-sm-8">
                <select name="type" class="form-control m-b" th:with="type=${@dict.getType('sys_notice_type')}">
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{type}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">标题：</label>
            <div class="col-sm-8">
                <input id="title" name="title" th:field="*{title}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">内容：</label>
            <div class="col-sm-8">
                <input id="content" name="content" th:field="*{content}" type="hidden">
                <div id="editor" class="summernote"></div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">附件：</label>
            <div class="col-sm-8">
                <input id="files" name="files" th:field="*{files}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">接收人：</label>
            <div class="col-sm-8">
               <!-- <input name="deptId"  type="hidden" id="treeId"/>-->
                <input name="userId"  type="hidden" id="userId"/>
                <input name="loginNames"  type="hidden" id="loginNames"/>
                <input class="form-control" type="text" name="userName" onclick="selectDeptTree()" readonly="true" id="userName">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">公告状态：</label>
            <div class="col-sm-8">
                <div class="radio-box" th:each="dict : ${@dict.getType('sys_notice_status')}">
                    <input type="radio" th:id="${dict.dictCode}" name="status" th:value="${dict.dictValue}" th:field="*{status}">
                    <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">备注：</label>
            <div class="col-sm-8">
                <input id="remark" name="remark" th:field="*{remark}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <div class="form-control-static col-sm-offset-9">
                <button type="submit" class="btn btn-primary">提交</button>
                <button onclick="$.modal.close()" class="btn btn-danger" type="button">关闭</button>
            </div>
        </div>
    </form>
</div>
<div th:include="include::footer"></div>
<script th:src="@{/ajax/libs/summernote/summernote.min.js}"></script>
<script th:src="@{/ajax/libs/summernote/summernote-zh-CN.js}"></script>
<script type="text/javascript">
    var prefix = ctx + "oa/notify";
    $(function() {
        $('.summernote').summernote({
            height : '220px',
            lang : 'zh-CN'
        });
        var content = $("#content").val();
        $('#editor').code(content);
    });
    $("#form-notify-edit").validate({
        rules: {
            title: {
                required: true,
            },
        },
        submitHandler: function (form) {
            var sHTML = $('.summernote').code();
            $("#content").val(sHTML);
            $.operate.save(prefix + "/edit", $('#form-notify-edit').serialize());
        }
    });

    /*用户管理-新增-选择部门树*/
   /* function selectDeptTree() {
        var treeId = $("#treeId").val();
        var deptId = $.common.isEmpty(treeId) ? "100" : $("#treeId").val();
        var url = ctx + "system/user/selectDeptTree/" + deptId;
        var options = {
            title: '选择通知人',
            width: "650",
            url: url,
            callBack: doSubmit
        };
        $.modal.openOptions(options);
    }

    function doSubmit(index, layero){
        var tree = layero.find("iframe")[0].contentWindow.$._tree;
        var body = layer.getChildFrame('body', index);
        $("#treeId").val(body.find('#treeId').val());
        var userId = "";
        var userName = "";
        body.find('input:checkbox[name="userId"]:checked').each(function(i) {
            if (0 == i) {
                userId = $(this).val();
                userName=$(this).next().html();
            } else {
                userId += ("," + $(this).val());
                userName +=("," + $(this).next().html());
            }
        });
        if (userId ==''){
            $.modal.msgError("没有选择用户");
        }else{
            $("#userName").val(userName);
            $("#userId").val(userId);
            layer.close(index);
        }
    }*/
    /*用户管理-新增-选择部门树*/
    function selectDeptTree() {
        var url = ctx + "system/user/userTree";
        $.modal.open("选择通知人", url);
    }
    function loadUser(userId,userName,loginNames) {
        $("#userName").val(userName);
        $("#userId").val(userId);
        $("#loginNames").val(loginNames);
    }
</script>
</body>
</html>